package cn.edu.njnu.opengmpback.Config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Value("${userServerLocation}")
    String userServerIpAndPort;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new MyInterceptor(userServerIpAndPort))
                .addPathPatterns(
                        "/user",
                        "/userRes/**",
                        "/computeModel/**",
                        "/project/**"
                )//拦截的请求
                .excludePathPatterns(
                        "/user/changePwd/**",
                        "/centerRes/**",
                        "/userRes/downloadDataItem/**"
                );//不拦截的请求
    }
}
